package homework.question4;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) throws ParseException {
        //目标:掌握JDK8以前版本时间类的使用(独立功能,独立成方法)
        //创建扫描器
        Scanner sc = new Scanner(System.in);
//        String time = "2015-10-20";
        String time = sc.next();

        //解析 String -> Date
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        //解析方法: public Date parse(String source)  把字符串解析成日期对象

        Date date = sdf.parse(time);
        //需求:将上面的date转换成Calendar对象
        //getInstance------>有重载的方法可以接时区
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        int year = calendar.get(Calendar.YEAR);
        int month = calendar.get(Calendar.MONDAY) + 1;
        int day = calendar.get(Calendar.DAY_OF_YEAR);
//        int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
        //支持%d的是printf 而不是println
        System.out.printf("转换后的日期: %d年%d月%d日%d一年的第几天", year, month, day);
//        System.out.printf("转换后的日期：%d年%d月%d日", year, month, day);
        System.out.println(day);


    }
}
